﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Movie.aspx.cs" Inherits="Movie" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>" 
        
        
    
        
        SelectCommand="SELECT Movie.MovieID, Movie.Title, Movie.Description, Movie.Length, Movie.Director, Category.Name AS Category, Movie.AvailabilityDate, Movie.Rating FROM Movie INNER JOIN CategoryMovie ON Movie.MovieID = CategoryMovie.MovieID INNER JOIN Category ON CategoryMovie.CategoryID = Category.CategoryID GROUP BY Category.Name, Movie.Director, Movie.Length, Movie.Description, Movie.Title, Movie.MovieID, Movie.AvailabilityDate, Movie.Rating HAVING (Movie.MovieID = @MovieID)">
        <SelectParameters>
            <asp:QueryStringParameter Name="MovieID" QueryStringField="MovieId" />
        </SelectParameters>
    </asp:SqlDataSource>

    <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" 
        DataKeyNames="MovieID" Width="334px">
        <EditItemTemplate>
            MovieID:
            <asp:Label ID="MovieIDLabel1" runat="server" Text='<%# Eval("MovieID") %>' />
            <br />
            Title:
            <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>' />
            <br />
            Description:
            <asp:TextBox ID="DescriptionTextBox" runat="server" 
                Text='<%# Bind("Description") %>' />
            <br />
            Length:
            <asp:TextBox ID="LengthTextBox" runat="server" Text='<%# Bind("Length") %>' />
            <br />
            Director:
            <asp:TextBox ID="DirectorTextBox" runat="server" 
                Text='<%# Bind("Director") %>' />
            <br />
            Category:
            <asp:TextBox ID="CategoryTextBox" runat="server" 
                Text='<%# Bind("Category") %>' />
            <br />
            AvailabilityDate:
            <asp:TextBox ID="AvailabilityDateTextBox" runat="server" 
                Text='<%# Bind("AvailabilityDate") %>' />
            <br />
            Rating:
            <asp:TextBox ID="RatingTextBox" runat="server" 
                Text='<%# Bind("Rating") %>' />
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Aktualisieren" />
            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Abbrechen" />
        </EditItemTemplate>
        <InsertItemTemplate>
            Title:
            <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>' />
            <br />
            Description:
            <asp:TextBox ID="DescriptionTextBox" runat="server" 
                Text='<%# Bind("Description") %>' />
            <br />
            Length:
            <asp:TextBox ID="LengthTextBox" runat="server" Text='<%# Bind("Length") %>' />
            <br />
            Director:
            <asp:TextBox ID="DirectorTextBox" runat="server" 
                Text='<%# Bind("Director") %>' />
            <br />
            Category:
            <asp:TextBox ID="CategoryTextBox" runat="server" 
                Text='<%# Bind("Category") %>' />
            <br />
            AvailabilityDate:
            <asp:TextBox ID="AvailabilityDateTextBox" runat="server" 
                Text='<%# Bind("AvailabilityDate") %>' />
            <br />
            Rating:
            <asp:TextBox ID="RatingTextBox" runat="server" 
                Text='<%# Bind("Rating") %>' />
            <br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                CommandName="Insert" Text="Einfügen" />
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Abbrechen" />
        </InsertItemTemplate>
        <ItemTemplate>
            MovieID:
            <asp:Label ID="MovieIDLabel" runat="server" Text='<%# Eval("MovieID") %>' />
            <br />
            Title:
            <asp:Label ID="TitleLabel" runat="server" 
                Text='<%# Bind("Title") %>' />
            <br />
            Description:
            <asp:Label ID="DescriptionLabel" runat="server" 
                Text='<%# Bind("Description") %>' />
            <br />
            Length:
            <asp:Label ID="LengthLabel" runat="server" Text='<%# Bind("Length") %>' />
            <br />
            Director:
            <asp:Label ID="DirectorLabel" runat="server" Text='<%# Bind("Director") %>' />
            <br />
            Category:
            <asp:Label ID="CategoryLabel" runat="server" 
                Text='<%# Bind("Category") %>' />
            <br />
            AvailabilityDate:
            <asp:Label ID="AvailabilityDateLabel" runat="server" 
                Text='<%# Bind("AvailabilityDate") %>' />
            <br />

            Rating:
            <asp:Label ID="RatingLabel" runat="server" Text='<%# Bind("Rating") %>' />
            <br />

        </ItemTemplate>
    </asp:FormView>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="CommentID" DataSourceID="SqlDataSource2" 
        onrowcommand="GridView1_RowCommand">
            <Columns>
                <asp:BoundField DataField="CommentID" HeaderText="CommentID" 
                    InsertVisible="False" ReadOnly="True" SortExpression="CommentID" />
                <asp:BoundField DataField="Comment" HeaderText="Comment" 
                    SortExpression="Comment" />
                <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
                <asp:ButtonField ButtonType="Button" CommandName="flagComment" 
                    Text="Flag Comment" />
            </Columns>
            <EmptyDataTemplate>
                Sorry no Comments made yet!
            </EmptyDataTemplate>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>" 
        SelectCommand="SELECT [Comment], [CommentID], [Date] FROM [Comment]">
    </asp:SqlDataSource>
    <asp:Button ID="btn_AddToRentalList" runat="server" 
        Text="Add to your rental List" onclick="btn_AddToRentalList_Click" />
    </asp:Content>

